﻿using System.Collections.Generic;

namespace HeroldIT.Dnn.JQuery.UI
{
    internal class DialogButtons : Dictionary<string, string>, ISettingSerializable
    {
        public bool IncludeSetting
        {
            get { return this.Count > 0; }
        }

        public string ToJson()
        {
            Dictionary<string, object> buttons = new Dictionary<string, object>(this.Count);
            foreach (KeyValuePair<string, string> button in this)
            {
                buttons[button.Key] = new ClientEventHandler("event", button.Value);
            }
            if (buttons.Count > 0)
            {
                return SettingSerializer.Serialize(buttons);
            }
            return "{}";
        }
    }
}
